//
//  XPPClassNames.m
//  XPPXcodePlugin
//
//  Created by yoyokko on 10-9-5.
//  Copyright 2010 yoyokko@gmail.com. All rights reserved.
//

#import "XPPClassName.h"

@implementation XPPVariable

@synthesize name = name_;
@synthesize type = type_;
@synthesize hasProperty = hasProperty_;
@synthesize isSelected = isSelected_;
@synthesize propertyName = propertyName_;
@synthesize propertyType = propertyType_;

- (id) init
{
	if (self = [super init])
	{
		self.name = nil;
		self.type = nil;
		self.hasProperty = NO;
		self.isSelected = NO;
		self.propertyName = nil;
		self.propertyType = @"nonatomic, retain";
	}
	return self;
}

#pragma mark Overridden Set Methods
- (void) setHasProperty:(BOOL) newValue
{
	hasProperty_ = newValue;
	// if this variable already has a property declaration, make it selected.
	hasProperty_ == YES ? (self.isSelected = YES) : 1;
}

- (void) setName:(NSString *) newValue
{
	newValue = [newValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
	if (name_ != newValue) {
		[name_ release];
		name_ = [newValue retain];
	}
	if ([name_ length] != 0) {
		self.propertyName = [name_ stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"_"]];
	}
}

- (void) dealloc
{
	self.name = nil;
	self.type = nil;
	
	[super dealloc];
}

@end


@implementation XPPClassName

@synthesize className = className_;
@synthesize variableNames = variableNames_;

- (id) initWithName:(NSString *) name
{
	if (self = [super init])
	{
		self.className = name;
	}
	return self;
}

- (void) dealloc
{
	self.className = nil;
	self.variableNames = nil;
	[super dealloc];
}

@end
